import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Register from '../views/Register.vue';
import Star from '../views/star.vue';

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Index.vue'),
    meta: { title: 'Home - Raccoon Guide' },
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
    meta: { title: 'Home - Raccoon Guide' },
  },
  {
    path: '/register',
    name: 'Register',
    component: Register,
    meta: { title: 'Home - Raccoon Guide' },
  },
  {
    path: '/Star',
    name: 'Star',
    component: Star,
    meta: { title: 'Home - Raccoon Guide' },
  },
];

const router = createRouter({
  history: createWebHistory('/'), 
  routes,
});

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title; 
  }
  next();
});

export default router;
